﻿using System;
using System.Windows;
using System.Windows.Browser;
using System.Windows.Controls;

namespace SoftSource.Resources
{
	public sealed partial class Master : UserControl
	{
		public Master()
		{
			// Required to initialize variables
			InitializeComponent();
            Loaded += new RoutedEventHandler(Master_Loaded);
		}

        void Master_Loaded(object sender, RoutedEventArgs e)
        {
            this.CopyrightText.Text = SoftSourceStrings.Copyright;
            this.ContactUsHyperlink.NavigateUri = new Uri(SoftSourceStrings.ContactUsURL, UriKind.RelativeOrAbsolute);
            this.PrivacyStatementHyperlink.NavigateUri = new Uri(SoftSourceStrings.PrivacyStatementURL, UriKind.RelativeOrAbsolute);
        }

        private void Branding_Click(object sender, RoutedEventArgs e)
        {
            HtmlPage.Window.Navigate(new Uri(SoftSourceStrings.RootURL, UriKind.RelativeOrAbsolute), "_blank");
        }


        public UIElement InfoBarContent
        {
            get { return (UIElement)GetValue(InfoBarContentProperty); }
            set { SetValue(InfoBarContentProperty, value); }
        }

        // Using a DependencyProperty as the backing store for InfoBarContent.  This enables animation, styling, binding, etc...
        public static readonly DependencyProperty InfoBarContentProperty =
            DependencyProperty.Register("InfoBarContent", typeof(UIElement), typeof(Master), new PropertyMetadata(null, (sender, e) =>
                {
                    Master master = sender as Master;
                    if (master != null)
                    {
                        master.InfoBar.Child = null;
                        master.InfoBar.Child = (UIElement)e.NewValue;
                    }
                }));


        
        public UIElement MainContent
        {
            get { return (UIElement)GetValue(MainContentProperty); }
            set { SetValue(MainContentProperty, value); }
        }

        // Using a DependencyProperty as the backing store for MainContent.  This enables animation, styling, binding, etc...
        public static readonly DependencyProperty MainContentProperty =
            DependencyProperty.Register("MainContent", typeof(UIElement), typeof(Master), new PropertyMetadata(null, (sender, e) =>
                {
                    Master master = sender as Master;
                    if (master != null)
                    {
                        master.ContentBorder.Child = null;
                        master.ContentBorder.Child = (UIElement)e.NewValue;
                    }
                }));



        public string ApplicationName
        {
            get { return (string)GetValue(ApplicationNameProperty); }
            set { SetValue(ApplicationNameProperty, value); }
        }

        // Using a DependencyProperty as the backing store for ApplicationName.  This enables animation, styling, binding, etc...
        public static readonly DependencyProperty ApplicationNameProperty =
            DependencyProperty.Register("ApplicationName", typeof(string), typeof(Master), new PropertyMetadata(string.Empty, (sender, e) =>
                {
                    Master master = sender as Master;
                    if (master != null)
                        master.ApplicationNameTextBlock.Text = (string)e.NewValue;
                }));



        public Visibility ContactBarVisibility
        {
            get { return (Visibility)GetValue(ContactBarVisibilityProperty); }
            set { SetValue(ContactBarVisibilityProperty, value); }
        }

        // Using a DependencyProperty as the backing store for ShowContactBar.  This enables animation, styling, binding, etc...
        public static readonly DependencyProperty ContactBarVisibilityProperty =
            DependencyProperty.Register("ContactBarVisibility", typeof(Visibility), typeof(Master), new PropertyMetadata(Visibility.Visible, (sender, e) =>
                {
                    Master master = sender as Master;
                    if (master != null)
                        master.ContactBar.Visibility = (Visibility)e.NewValue;
                }));


	}
}